From b65af759f14e6d0f46fc86afbb71cfeca6aef9e9 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sun, 8 Sep 2019 18:50:13 +0200 Subject: [PATCH] RequestContext: Declare the dynamic property for language recursion Change-Id: I601f98190cb8f760541ba1f05a3070fc43c25ccb --- includes/context/RequestContext.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index e6a856cf12..cbcaba1c9f 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -81,6 +81,12 @@ class RequestContext implements IContextSource, MutableContext { */ private static $instance = null; + /** + * Boolean flag to guard against recursion in getLanguage + * @var bool + */ + private $languageRecursion = false; + /** * @param Config $config */ @@ -318,7 +324,7 @@ class RequestContext implements IContextSource, MutableContext { * @since 1.19 */ public function getLanguage() { - if ( isset( $this->recursion ) ) { + if ( $this->languageRecursion === true ) { trigger_error( "Recursion detected in " . __METHOD__, E_USER_WARNING ); $e = new Exception; wfDebugLog( 'recursion-guard', "Recursion detected:\n" . $e->getTraceAsString() ); @@ -326,7 +332,7 @@ class RequestContext implements IContextSource, MutableContext { $code = $this->getConfig()->get( 'LanguageCode' ) ?: 'en'; $this->lang = Language::factory( $code ); } elseif ( $this->lang === null ) { - $this->recursion = true; + $this->languageRecursion = true; try { $request = $this->getRequest(); @@ -348,7 +354,7 @@ class RequestContext implements IContextSource, MutableContext { $this->lang = $obj; } } finally { - unset( $this->recursion ); + $this->languageRecursion = false; } } -- 2.20.1